﻿
//
//
//

namespace Microsoft.OpenTurf.Silverlight.Shared
{
    using System;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;

    public class GenericFeedItem : IFeedItem
    {
        #region ctor
        public GenericFeedItem()
        {

        }
        #endregion

        public string ID { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public Uri Link { get; set; }
        public Uri Icon { get; set; }
        public string CoordinateList { get; set; }
        public List<MapPoint> Coordinates { get { return CreateMapPoints(); } }

        public List<MapPoint> CreateMapPoints()
        {
            List<MapPoint> points = new List<MapPoint>();

            foreach (Match geoCode in Regex.Matches(CoordinateList, AppGlobals.GEO_CODE_PATTERN))
            {
                string[] pair = geoCode.Value.Split(new char[] { ',' });
                double latitude = Double.Parse(pair[0]);
                double longitude = Double.Parse(pair[1]);

                MapPoint point = new MapPoint(latitude, longitude);

                points.Add(point);
            }
            return points;
        }
    }
}
